home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / ms_dos / check / check101 / check.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-07-08  |  5.2 KB  |  168 lines

  1. Program check;
  2. uses dos,crt;
  3.  
  4. const
  5.    {カラーテーブル設定}
  6.    kuro=0;Ao=1;Midori=2;Mizuiro=3;Aka=4;Kiiro=6;Murasaki=5;Shiro=7;
  7.    CrChar ='';{ ^M;}         (* 改行文字 ここでは使っていない*)
  8.  
  9. {$I check.lib}
  10.    
  11. var
  12.    jisyo1,jisyo2,jisyo3,
  13.    STringLine,tango,tango_file2,filename,ws,lineNo:string;
  14.    flag,i,j,KURIKAESHI,linecounter:integer;
  15.    hensyufile:text;
  16.    ch:char;
  17.    dammy:string[1];
  18.    bword,word:array[1..80] of string;{一文中の単語数の許容範囲}
  19.  
  20. begin
  21. {===初期の表示=====完成=====================================}
  22.    HeapError := @HeapFunc;
  23.    title;
  24.    line;
  25.    {backcolor(ao);}
  26. {===辞書ファイルの初期化========完成================================}
  27.    config(jisyo1,jisyo2,jisyo3); {辞書ファイルの設定jisyo1,jisyo2,jisyo3は辞書}
  28.    {1:無かったら新規作成 2:無かったら終了 3:あっても新規作成}
  29.    CheckFileExist(2,jisyo1);
  30.    CheckFileExist(1,jisyo2);
  31.    CheckFileExist(3,jisyo3);
  32. {===編集ファイルの選択========完成================================}
  33.    case paramcount of
  34.       0:begin
  35.           repeat
  36.             write('編集対象のファイル名を与えて下さい>');
  37.             readln(filename);
  38.             openfile(filename,hensyufile,flag);
  39.             linecounter:=1;j:=0;
  40.           until flag=0;
  41.         end;
  42.       1:begin
  43.           filename:=paramstr(1);
  44.           linecounter:=1;j:=0;
  45.           openfile(filename,hensyufile,flag);
  46.           if flag=1 then 
  47.              begin
  48.                textcolor(aka);
  49.                writeln(^G+'コマンドエラー');
  50.                textcolor(shiro);
  51.                writeln('使い方');
  52.                writeln('CHECK [ファイル名:String] [行番号:integer]');
  53.                halt(1);
  54.              end;
  55.         end;
  56.       2:begin
  57.           filename:=paramstr(1);
  58.           linecounter:=1;j:=0;
  59.           openfile(filename,hensyufile,flag);
  60.           if flag=1 then 
  61.              begin
  62.                textcolor(aka);
  63.                writeln(^G+'コマンドエラー');
  64.                textcolor(shiro);
  65.                writeln('使い方');
  66.                writeln('CHECK [ファイル名:String] [行番号:integer]');
  67.                halt(1);
  68.              end
  69.            else 
  70.              begin
  71.                lineNo:=paramstr(2);
  72.                val(lineNo,j,flag);
  73.                if flag=1 then halt(1);
  74.              end;
  75.         end;
  76.    end;{end of case}
  77.    
  78.    
  79. {===一文を文書ファイルより切り取り単語に分解===完成====================}
  80. repeat {一番大きな repeat }
  81.  line;
  82.  {linecounter:=linecounter+1;}
  83.  if j>linecounter then 
  84.     begin
  85.       if (not(paramstr(1)='') and (flag=0)) then 
  86.          begin
  87.            repeat
  88.              readln(hensyufile,STRINGline);linecounter:=linecounter+1;
  89.            until linecounter=j;
  90.          end;
  91.     end;
  92.  
  93.  textcolor(kiiro);
  94.  writeln('この行は ',filename,' の ',linecounter,' 行目です。');
  95.  textcolor(shiro);
  96.  
  97.  repeat
  98.      readln(hensyufile,STRINGline);linecounter:=linecounter+1;
  99.  until ( eoln(hensyufile) or eof(hensyufile) or (stringline<>''));
  100.  
  101. { 単語に分解するルーチン 完成}
  102.    i:=0;
  103.    repeat
  104.       Ws:='';
  105.       repeat
  106.         dammy:=copy(STRINGline,1,1);
  107.         if not ((dammy='!') or (dammy='?') or (dammy=' ') or
  108.                (dammy=':') or (dammy='.') or (dammy='')) then WS:=WS+dammy;
  109.         delete(STringLine,1,1);
  110.       until ((dammy='!') or (dammy='?') or (dammy=' ') or
  111.                (dammy=':') or (dammy='.') or (dammy=''));
  112.       if ws<>'' then
  113.         begin
  114.           i:=i+1;
  115.           Word[i]:=WS;
  116.         end;
  117.    until STringLine='';
  118. { 単語に分解するルーチン <-- ここで終わり}
  119.     
  120. {====辞書を検索し結果を表示するルーチン=================================}
  121.    for KURIKAESHI:=1 to i do
  122.     begin
  123.      if ((word[KURIKAESHI]<>'') or (word[KURIKAESHI]='' )) 
  124.          then bword[KURIKAESHI]:=word[KURIKAESHI];
  125.      SearchWordfromDIC(jisyo2,bword[KURIKAESHI],tango);
  126.      tango_file2:=tango;
  127.      if tango='' then SearchWordfromDIC(jisyo1,bword[KURIKAESHI],tango);
  128.     {↓辞書2になくて辞書1にあった場合に辞書2に書き込む}
  129.        if ((tango_file2='') and (tango<>'')) then
  130.           DataPlus2File(jisyo2,bword[KURIKAESHI]);
  131.        if tango='' 
  132.           then 
  133.             begin
  134.               textcolor(mizuiro);
  135.               write(bword[KURIKAESHI]);
  136.               textcolor(shiro);
  137.               writeln(':この単語は存在しません。');
  138.               textcolor(aka);
  139.               writeln(^G+'辞書3に保存しておきますか [Y/N]');
  140.               textcolor(shiro);
  141.               repeat
  142.                 ch:=readkey;
  143.               until ch in ['y','Y','n','N'];
  144.               if ch in ['y','Y'] then 
  145.                  begin
  146.                     {↓辞書2と辞書1のどちらにも無い場合のみ辞書3に書き込む}
  147.                     DataPlus2File(jisyo3,bword[KURIKAESHI]);
  148.                     writeln('保存しました');
  149.                  end;
  150.             end
  151.           else 
  152.              begin
  153.                 textcolor(mizuiro);
  154.                 write(bword[KURIKAESHI]);
  155.                 textcolor(shiro);
  156.                 writeln(':この単語は存在します。');
  157.              end;
  158.     end;{of for}
  159.  
  160. until eof(hensyufile);
  161. {これは一番大きな繰り返しのrepeatに対応するuntil}
  162.    close(hensyufile);
  163.    {backcolor(kuro);}
  164.    textcolor(shiro);
  165.    halt(0);
  166. end.
  167.  
  168.